<template>
  <div>
    <div class="outer_label">
      <img class="inner_label login_logo"
           src="../../assets/logo.png">
    </div>
    <div class="login_form">
      <input type="text"
             class="qxs-ic_user qxs-icon"
             placeholder="用户名"
             v-model="userName">
      <input type="text"
             class="qxs-ic_password qxs-icon"
             placeholder="密码"
             v-model="password">
      <el-button class="login_btn"
                 @click.native="login"
                 type="primary"
                 round
                 :loading="isBtnLoading">登录</el-button>
      <el-button class="register_btn"
                 round
                 type="primary">注册</el-button>
      <div style="margin-top: 10px">
        <span style="color: #000099;"
              @click="login">司机账号登陆</span><span style="float: right;color: #A9A9AB">忘记密码？</span>
      </div>
      <zy-menu></zy-menu>
    </div>
  </div>
</template>
<script>

import { throws } from 'assert'
import zyMenu from '@/components/common/Menu.vue'
export default {
  components: {
    zyMenu
  },
  data () {
    return {
      userName: '',
      password: '',
      isBtnLoading: false
    }
  },
  beforeCreate () {
    console.log("创建前：");
    console.log(this.$el);
    console.log(this.$data);
  },
  created () {
    console.log("创建完成");
    if (JSON.parse(localStorage.getItem('user')) && JSON.parse(localStorage.getItem('user')).userName) {
      this.userName = JSON.parse(localStorage.getItem('user')).userName;
      this.password = JSON.parse(localStorage.getItem('user')).password;
    }
  },
  beforeMount () {
    console.log("挂载前：");
    console.log(this.$el);
    console.log(this.$data);
  },
  mounted () {

    //this.foo();
    console.log("挂载完成：");
    console.log(this.$el);
    console.log(this.$data);
  },
  beforeUpdate () {
    console.log('=即将更新渲染=');
    //let name = this.$refs.app.innerHTML;
    //console.log('name:' + name);
  },
  updated () {
    console.log('==更新成功==');
    //let name = this.$refs.app.innerHTML;
    //console.log('name:' + name);
  },
  /*beforeDestory(){
      console.log("销毁前：");
  },
  destoryed(){
      console.log("销毁完成：");
  }*/

  computed: {
    btnText () {
      if (this.isBtnLoading) return '登录中...';
      return '登录';
    }
  },
  methods: {
    login: function () {
      if (!this.userName) {
        this.$message.error('请输入用户名');
        return;
      }
      if (!this.password) {
        this.$message.error('请输入密码');
        return;
      }

      let path = this.$store.state.baseUrl + '/home/LoingTest';

      console.log(path);
      this.$axios.get(path, {
        params: {
          username: this.userName,
          password: this.password
        }
      }).then((response) => {
        let res = response.data;
        console.log(res);
        this.$cookies.set('xkw.zy.token', res.data);
        //this.$router.push('/user/userindex');
      });
    }
  },

}
</script>
<style>
.login_form {
  padding-top: 10%;
  padding-left: 10%;
  padding-right: 10%;
}
.qxs-ic_user {
  background: url("../../assets/login/ic_user.png") no-repeat;
  background-size: 13px 15px;
  background-position: 3%;
}
.qxs-ic_password {
  background: url("../../assets/login/ic_password.png") no-repeat;
  background-size: 13px 15px;
  background-position: 3%;
  margin-bottom: 20px;
}
.login_logo {
  height: 100%;
}
.login_btn {
  width: 40%;
  font-size: 16px;
  background: -webkit-linear-gradient(
    left,
    #500d21,
    #2154fa
  ); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(
    right,
    #990026,
    #2154fa
  ); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(
    right,
    #990021,
    #2154fa
  ); /* Firefox 3.6 - 15 */
  background: linear-gradient(to right, #9a2aa8, #2154fa); /* 标准的语法 */
  filter: brightness(1.4);
}

.register_btn {
  width: 40%;
  font-size: 16px;
  background: -webkit-linear-gradient(
    left,
    #000099,
    #2154fa
  ); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(
    right,
    #000099,
    #2154fa
  ); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(
    right,
    #000099,
    #2154fa
  ); /* Firefox 3.6 - 15 */
  background: linear-gradient(to right, #000099, #2154fa); /* 标准的语法 */
  filter: brightness(1.4);
}
</style>